home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!lorelei.demon.co.uk
- From: John Croudy <john@lorelei.demon.co.uk>
- Newsgroups: comp.lang.c++
- Subject: Operator Overloading
- Date: Sun, 7 Apr 96 19:05:44 GMT
- Organization: home
- Message-ID: <9604071905.AA001o6@lorelei.demon.co.uk>
- X-NNTP-Posting-Host: lorelei.demon.co.uk
- X-Newsreader: TIN [AMIGA 1.3 950726BETA PL0]
- X-Mail2News-Path: disperse.demon.co.uk!post.demon.co.uk!lorelei.demon.co.uk
-
- Hello,
-
- I have a question which I can't find the answer to in any of my books.
- It's very frustrating how books always seem to go into detail about what
- a pointer is (which I already know from C) but they always stop after
- introducing the advanced stuff. I bought the books to learn C++ and
- they're 80% about C stuff, and the juicy stuff is skipped over... like
- two pages on templates and a paragraph on references. So I thought I'd
- ask here, because it's been driving me nuts.
-
- Does anyone know about this form in C++:
-
- operator void*() const { return something; }
-
- I found it in <streambuf.h> ... it seems to support the following
-
- ofstream file("TEST.DAT");
-
- if (file) // File was opened ok
-
- I then tried this:
-
- class MyClass
- ...
- operator double () const { return something; }
- ...
-
- and it seems to allow me to say
-
- double x;
-
- x = MyClass;
-
- It seems to be a user-defined casting operator, but I can't find any
- mention of this in any books I have. Can anyone explain what I have
- discovered here?
-
- Thanks,
-
- John
- xxxx
-